import Route from './Route';

export default class RouteMap {
    routes = [];
    add(route) {
        if (route instanceof Route) {
            this.routes.push(route);
        }
    }
    matchRoute(method, path) {
        let matched;
        for (let index = 0; index < this.routes.length; index++) {
            const route = this.routes[index];
            const result = route.getMatched(method, path);
            if (result) {
                matched = result;
                break;
            }
        }

        return matched;
    }
}
